1. Field of the Invention
Apparatuses and methods consistent with the present invention relate to increasing task-execution speed, and, more particularly, to increasing task-execution speed by compiling code to bytecode, and executing native code in units of blocks instead of bytecode, in which a block is a group of a series of bytecodes.
2. Description of the Related Art
Java is an object-oriented programming language that can be executed on any platform. A platform refers to hardware on which a program or software such as an operating system (OS) runs. Code written in Java is compiled into bytecode by a Java compiler, and the bytecode is executed by a Java virtual machine ported on various platforms.
Bytecode is a command language, such as a machine language, and is not dependent on a particular processor. Bytecode is executed by a virtual machine. That is, the virtual machine interprets the bytecode into corresponding native code. Since the bytecode is not limited to a particular architecture, it can run on any architecture having the Java virtual machine. Accordingly, a binary bytecode file can be executed in a platform-independent manner.
However, a major drawback of Java is execution speed. A program compiled on a particular architecture runs faster than bytecode because it runs directly on hardware without requiring a processor architecture to be emulated on another processor architecture.
With bytecode, the Java virtual machine running on a processor has to convert the bytecode into native code before starting its operation.
Various hardware or software technologies are being tried in order to increase the execution speed of the bytecode. For example, software technology such as a just-in-time (JIT) compiler or a hotspot JIT compiler, which are faster than the JIT compiler, have been used to increase the speed of the Java virtual machine. The JIT compiler accompanies compile overhead and memory overhead when generating a native processor command.
As hardware technologies for increasing the interpretation speed of bytecode, a technology of modifying processor architecture and a technology of using an external processor are being tried.
FIG. 1 is a flowchart illustrating a conventional method of converting bytecode into native code and executing the native code.
Referring to FIG. 1, a software routine running on a central processing unit (CPU) loads bytecode, and a processor transmits the bytecode or an address of the bytecode to a Java interpretation accelerator (S10). When the address of the bytecode is transmitted, the bytecode located at the address may be called.
Then, the bytecode is input to a state machine included in a bytecode interpreter, and the state machine searches a native code cache for a cached and interpreted version of the bytecode, that is, native code (S20). If the native code is found in the native code cache, its address is transmitted to the processor (S60). Accordingly, native code is sequentially executed from the native code located at the address (S70).
If the native code is not found in the native code cache, the state machine searches a bytecode-interpretation lookup table (S30). The bytecode-interpretation lookup table denotes information stored in order to map or convert bytecode. It is determined whether the bytecode exists in the lookup table (S40). If the bytecode does not exist, the process ends. If the bytecode does exist in the lookup table, an interpreted version of the native code is copied to the native code cache (S50). The processor receives an address of the native code in the native code cache (S60), and executes commands corresponding to native code, starting with a command corresponding to the native code located at the address (S70).
After native code for the finally interpreted bytecode is executed, a control right is transferred to a software or hardware routine responsible for resuming the interpretation of the next bytecode. Such a handoff is performed in the final stage of executing the interpreted bytecode.
However, since the handoff causes a performance loss due to the extra overhead, an invention that can enhance system performance by reducing the frequency of handoffs is needed.